import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '../components/login.vue'
import home from '../components/home.vue'
import user from '../components/User/user.vue'
import product from '../components/Product/product.vue'
import order from '../components/Order/order.vue'
import category from '../components/Category/category.vue'
Vue.use(VueRouter)

const routes = [
  //默认路由
  {
    path: "*",
    redirect: '/login'
  },
  //登录页面
  {
    path: '/login',
    name: 'login',
    component: login
  },
  //主页路由
  {
    path: '/home',
    component: home,
    children: [
      //用户管理界面
      {
        path: '/user',
        component: user,
      },
      //商品管理界面
      {
        path: '/product',
        component: product
      },
      //分类管理页面
      {
        path: '/category',
        component: category
      },
      //订单管理界面
      {
        path: '/order',
        component: order
      },
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
